<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021/3/29 0029
 * Time: 14:11
 */

namespace app\admin\logic;


use think\facade\Request;

class OrderLogic
{
    //留值
    public static function oData(){
        $param=Request::param();
        $data=[
            'keywords'=>isset($param['keywords'])?$param['keywords']:'',
            'cid'=>isset($param['cid'])?$param['cid']:[],
            'maxtime'=>isset($param['maxtime'])?$param['maxtime']:'',
            'mintime'=>isset($param['mintime'])?$param['mintime']:'',
            'maxprice'=>isset($param['maxprice'])?$param['maxprice']:'',
            'minprice'=>isset($param['minprice'])?$param['minprice']:'',
        ];
        return $data;
    }
    //where
    public static function oWhere(){
        $param=Request::param();
        $where=[];
        if (isset($param['keywords']) && !empty($param['keywords'])){
            $where[]=['o.order_sn','like','%'.$param['keywords'].'%'];
        }
        if (isset($param['cid']) && count($param['cid'])==1){
            $where[]=['o.status','in',$param['cid']];
        }
        if (isset($param['maxtime']) && !empty($param['maxtime'])){
            $max=strtotime($param['maxtime']);
            $where[]=['o.add_time','<=',$max];
        }
        if (isset($param['mintime']) && !empty($param['mintime'])){
            $min=strtotime($param['mintime']);
            $where[]=['o.add_time','>=',$min];
        }
        if (isset($param['maxprice']) && !empty($param['maxprice'])){

            $where[]=['o.order_amount','<=',$param['maxprice']];
        }
        if (isset($param['minprice']) && !empty($param['minprice'])){

            $where[]=['o.order_amount','>=',$param['minprice']];
        }
        return $where;

    }
}